const mongoose = require('mongoose');

const ChallengeSchema = new mongoose.Schema({
  title: {
    type: String,
    required: true
  },
  description: {
    type: String,
    required: true
  },
  pattern: {
    type: mongoose.Schema.Types.ObjectId,
    ref: 'Pattern',
    required: true
  },
  level: {
    type: String,
    required: true,
    enum: ['beginner', 'intermediate', 'advanced']
  },
  scenario: {
    type: String,
    required: true
  },
  requirements: {
    type: [String],
    required: true
  },
  hints: {
    type: [String],
    default: []
  },
  sampleSolution: {
    type: String,
    required: true
  },
  testCases: {
    type: [{
      input: String,
      expectedOutput: String,
      description: String
    }],
    default: []
  },
  timeLimit: {
    type: Number,  // in minutes
    default: 30
  },
  difficulty: {
    type: Number,  // 1-10 scale
    required: true,
    min: 1,
    max: 10
  },
  tags: {
    type: [String],
    default: []
  }
}, {
  timestamps: true
});

module.exports = mongoose.model('Challenge', ChallengeSchema); 